package com.wxyzz.satserver.recharge.service.impl;
import com.wxyzz.common.core.entity.Recharge;
import com.wxyzz.common.core.utils.UserUtils;
import com.wxyzz.satserver.recharge.dao.BuyDao;
import com.wxyzz.satserver.recharge.param.BuyParam;
import com.wxyzz.satserver.recharge.service.BuyService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class BuyServiceImpl implements BuyService {

    @Resource
    private BuyDao buyDao;

    @Override
    public String addRecharge(BuyParam param) {

//        Integer uid = UserUtils.getUid();

        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
        String orderNo = sdf.format(new Date());
        Recharge recharge = new Recharge();
        BeanUtils.copyProperties(param, recharge);
        recharge.setUid(1);
        recharge.setOrderNo(orderNo);
        buyDao.insert(recharge);

        return orderNo;
    }
}
